<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app"></div>
    <script src="./vue.js"></script>
    <script>
      /*
        1. 如果想要操作对象，最早可以在created中操作
        2. 如果想要操作DOM，最早可以在mounted中操作
        周期函数
        beforeCreate
        created
        beforeMount
        mounted
        beforeUpdate
        updated
        beforDestroy
        detroyd
      */
      new Vue({
        el: "#app",
        template: `
            <div id="box">
                hello  
                <b v-if="flag">jack</b>
            </div>
            `,
        data: {
          flag: true,
        },
        created() {
          setTimeout(() => {
            this.flag = false;
          }, 5000);
        },

        beforeUpdate() {
          // 更新前
          console.log("beforeUpdate");
          console.log(document.getElementById("box").innerHTML);
        },
        updated() {
          // 更新后
          console.log("updated");
          console.log(document.getElementById("box").innerHTML);
        },

        methods: {},
      });
    </script>
  </body>
</html>
